package com.flash.BusinessParameters.service.impl;

import com.flash.BusinessParameters.entity.ExchangeRate;
import com.flash.BusinessParameters.mapper.ExchangeRateMapper;
import com.flash.BusinessParameters.service.ExchangeRateService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
@Service
public class ExchangeRateServiceImpl implements ExchangeRateService {
    @Resource
    ExchangeRateMapper exchangeRateMapper;

    @Override
    public List<ExchangeRate> selectExchangeRate() {
        return exchangeRateMapper.selectExchangeRate();
    }


    @Override
    public List<ExchangeRate> selectExchangeRateMap(int exchangeName, int page, int limit) {
        HashMap map = new HashMap<>();
        map.put("page",(page-1)*limit);
        map.put("limit",limit);
        if (exchangeName!=0){
            map.put("strWhere"," and exchangeName = "+exchangeName);
        }else {
            map.put("strWhere","");
        }

        return exchangeRateMapper.selectExchangeRateMap(map);
    }

    @Override
    public int selectCountExchangeRate() {
        return exchangeRateMapper.selectCountExchangeRate();
    }

    @Override
    public int insertExchangeRate(ExchangeRate exchangeRate) {
        return exchangeRateMapper.insertExchangeRate(exchangeRate);
    }

    @Override
    public int deleteExchangeRate(int exchangeName) {
        return exchangeRateMapper.deleteExchangeRate(exchangeName);
    }

    @Override
    public int updateExchangeRate(ExchangeRate exchangeRate) {
        return exchangeRateMapper.updateExchangeRate(exchangeRate);
    }

    @Override
    public List<ExchangeRate> selectExchangeRateMap2(int exchangeType) {
        return exchangeRateMapper.selectExchangeRateMap2(exchangeType);
    }


}
